/*
 * GraphThread.java
 *
 * This file is part of FUJIWARA.
 * Copyright (C) 2010 Loris Fichera    (loris.fichera@gmail.com)
 *                    Daniele Marletta (danielemar86@gmail.com)
 *
 * FUJIWARA is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FUJIWARA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with FUJIWARA.  If not, see <http://www.gnu.org/licenses/>.
 */

package graphclient;

/**
 *
 * @author Loris Fichera
 * @author Daniele Marletta
 */
public class GraphThread extends Thread {

    private int [] hops;
    private int [] adjVector;
    private int [] neighboursCount;
    private int hypernode;
    private GraphPartitioningStrategy strategy;

    // disable default constructor
    private GraphThread ( ) { }
    
    public GraphThread ( int [] adjVector, 
                         int [] neighboursCount,
                         int hypernode,
                         GraphPartitioningStrategy strategy) {
        
        this.hops = null;
        this.adjVector = adjVector;
        this.neighboursCount = neighboursCount;
        this.hypernode = hypernode;
        this.strategy = strategy;
    }

    @Override() public void run () {

        this.hops = strategy.computeHops (adjVector, neighboursCount, hypernode);
        
    }

    public int [] getHops () {
        if ( this.isAlive() )
            System.out.println("Warning. Thread " + this.getName() +
                               " has not terminated yet.");
        return hops;
    }
}
